import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// 自动导包需下载 npm i unplugin-auto-import -D 配置AutoImport
import AutoImport from "unplugin-auto-import/vite"
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import {resolve} from "path"
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
      import:['vue','vue-router']
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    }),
  ],
  server:{
    cors:true,
    proxy:{
      '/api':{
        target: 'http://8.130.136.203:9000/',
        changeOrigin: true,
        rewrite: path=>path.replace(/^\/api/,'')
      },
      '/admin':{
        target: 'http://localhost:8083',
        changeOrigin: true,
        rewrite: path=>path.replace(/^\/admin/,'')
      }
    }
  },
  resolve: {
    //配置路径别名
    alias:{
      '@': resolve(__dirname,'./src')
    }
  },
  
})
